import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Description:
 * Author: Hank
 * Date: 2018/8/6 21:58
 */

public class PrimitiveServlet implements Servlet {
    @Override
    public void init(ServletConfig config) throws ServletException {
        System.out.println("init");
    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        String result="Hello world";
        System.out.println("from service");
        PrintWriter out = res.getWriter();
        out.println("HTTP/1.1 200 OK");
        out.println("Content-type: text/html");
        out.println("Content-length: "+result.length());
        out.println("");
        out.println(result);
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        System.out.println("destory");
    }
}
